package 比较排序;

public class InsertSort {
    public static void sort(int[] arr){
        int pre,current;
        for(int i=1;i<arr.length;i++){
            pre=i-1;
            current=arr[i];
            //把小于 current 的数字不断往前推
            while (pre>=0 && arr[pre]>current){
                arr[pre+1]=arr[pre];
                pre--;
            }
            arr[pre+1]=current;
        }
    }
}
